package com.yuanqi.java.entity;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.Instant;
import java.util.LinkedHashSet;
import java.util.Set;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

@Getter
@Setter
@Entity
@Table(name = "supplier", schema = "ERP-Sales")
public class Supplier {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @Size(max = 64)
    @NotNull
    @Column(name = "supplier_code", nullable = false, length = 64)
    private String supplierCode;

    @Size(max = 256)
    @NotNull
    @Column(name = "supplier_name", nullable = false, length = 256)
    private String supplierName;

    @Size(max = 128)
    @Column(name = "contact_name", length = 128)
    private String contactName;

    @Size(max = 32)
    @Column(name = "phone", length = 32)
    private String phone;

    @Size(max = 128)
    @Column(name = "email", length = 128)
    private String email;

    @Size(max = 64)
    @Column(name = "tax_no", length = 64)
    private String taxNo;

    @Size(max = 512)
    @Column(name = "address", length = 512)
    private String address;

    @NotNull
    @Column(name = "payment_term_days", nullable = false)
    private Integer paymentTermDays;

    @NotNull
    @Column(name = "status", nullable = false)
    private Byte status;

    @NotNull
    @Column(name = "created_at", nullable = false)
    private Instant createdAt;

    @NotNull
    @Column(name = "updated_at", nullable = false)
    private Instant updatedAt;

}